﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sys = Cosmos.System;
using FAT = Cosmos.System.Filesystem.FAT;
using Cosmos.Hardware.BlockDevice;
using Gynx.FileSystem.FAT;

namespace Gynx.Parser
{
    class CommandLineParser 
    {
        private string[] names = new string[4] {"man", "cls", "ls", "sys"};
        private FatSupport fatSupport = null;
        public void parseCommand(String command, String[] arguments)
        {
            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.WriteLine("-----------------------------------------------------------");

            switch (command)
            {
                case "man" :
                    String argument = arguments[0];
                    switch (argument) 
                    {
                        case "cls" :
                            Console.WriteLine("cls: Clears the whole console.");
                            break;
                        case "ls" :
                            Console.WriteLine("ls: Prints a list of all the files and subdirectories in the current directory.");
                            break;
                        case "sys" :
                            Console.WriteLine("sys: Print all the system information.");
                            break;
                        default :
                            Console.WriteLine("man: A manual page for all the possible commands. Explains the usage and the possible commands.");
                            Console.Write("Commands: ");
                            for (int i = 0; i < names.Length; i++)
                            {
                                Console.Write(names[i] + ",");
                                
                            
                            }
                            Console.Write("\n");
                            Console.WriteLine("Usage: man <command>");
                            break;
                    }
                    Console.WriteLine("-----------------------------------------------------------");
                    break;
                
                case "ls" :
                    Console.ForegroundColor = ConsoleColor.DarkCyan;
                    Console.WriteLine("Displaying files at / ");
                    Console.WriteLine("--------------------");
                    Console.ForegroundColor = ConsoleColor.Magenta;
                    fatSupport = new FatSupport();
                    fatSupport.Start();
                    fatSupport.ListFiles();
                    break;
                case "cls":
                    Console.Clear();
                    break;
                case "sys":
                    fatSupport.Start();
                    Console.WriteLine("DriveType: " + fatSupport.GetDriveType());
                    Console.WriteLine("SerialNumber: " + fatSupport.GetDeviceSerialNumber());
                    Console.WriteLine("ModelNumber: " + fatSupport.GetDeviceModelNumber());
                    Console.WriteLine("BlockSize: " + fatSupport.GetDeviceBlockSize());
                    Console.WriteLine("Size :" + fatSupport.GetDriveSize());
                    break;
                default:
                    Console.WriteLine("Unknown command: " + command);
                    break;
            }
        }



    }
}
